'use strict';

angular.module('CBO').controller('DeviceMonitorListController', ['$scope', 'BaseModule', 'BaseEnum', 'CBOEnum', 'Authentication',
    function($scope, BaseModule, BaseEnum, CBOEnum, Authentication) {
        $scope.ExecuteResultEnum = CBOEnum.ExecuteResult;

        BaseModule.initModule($scope, 'DeviceMonitor');
        $scope.Module.DeviceMonitor.Condition = {IsProcess: {$ne: true}};
        $scope.Module.DeviceMonitor.OrderBy = {RequestTime: -1};
        $scope.Module.DeviceMonitor.LoadMode = BaseEnum.LoadMode.CacheAndPaging;
        $scope.Module.DeviceMonitor.PageSize = 15;

        $scope.btnProcess = function(){
            var selectedRecords = $scope.Module.DeviceMonitor.SelectedRecords;
            var isBeSave = false;
            for(var i=0; i<selectedRecords.length; i++){
                if(!selectedRecords[i].IsProcess){
                    selectedRecords[i].IsProcess = true;
                    selectedRecords[i].RowStatus = BaseEnum.RowStatus.Modify.Value;
                    isBeSave = true;
                }
            }
            if(isBeSave){
                $scope.Module.DeviceMonitor.save();
            }
        };
    }
]);